/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Presentation;

import BLO.HLVBLO;
import BLO.TrongtaiBLO;
import DAO.ResultsModel;
import DTO.HLV;
import DTO.NGUOI;
import DTO.Function;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
import DAO.ResultsModel;
import DAO.Result;
import DAO.Connect;
import DTO.TRONGTAI;
import java.util.Calendar;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

/**
 *
 * @author LUCKYSTARS
 */
public class QLTT_HLV extends javax.swing.JPanel {

    NGUOI ngDTO = new NGUOI();
    
    HLVBLO hlvBLO = new HLVBLO();
    HLV hlvDTO = new HLV();
    
    TRONGTAI ttDTO = new TRONGTAI();
    TrongtaiBLO ttBLO = new TrongtaiBLO();
    
    int tab = 1;
    
    String strHLV = "";
    String strTT = "";
    
    
    
    
    public QLTT_HLV() {
        
        initComponents();
        
          try {
            ResultsModel dtable = hlvBLO.Getdata1();
            JTable tb = new JTable(dtable);
            tb.setBounds(0, 0, 869, 300);
            JScrollPane js = new JScrollPane(tb);
            js.setBounds(0, 0, 869, 300);
            dgvHLV.removeAll();
            dgvHLV.add(js);
            
            ResultsModel dtable1 = ttBLO.Getdata1();
            JTable tb1 = new JTable(dtable1);
            tb1.setBounds(0, 0, 869, 300);
            JScrollPane js1 = new JScrollPane(tb1);
            js1.setBounds(0, 0, 869, 300);
            dgvTrongTai.removeAll();
            dgvTrongTai.add(js1);



            //sinh ma HLV
            Function fn = new Function();
              String st;
               if(hlvBLO.LayMaCuoi().trim().length()==0)
                  st="HL_00";
              else
                 st= hlvBLO.LayMaCuoi().trim();
           
            strHLV = fn.ID_Ketiep(st, "HL_");
            txtMaHLV.setText(strHLV);

            //Sinh ma TT
            String st1;
               if(ttBLO.LayMaCuoi().trim().length()==0)
                  st1="TT_00";
              else
                 st1 = ttBLO.LayMaCuoi().trim();
           
            strTT = fn.ID_Ketiep(st1, "TT_");
            txtMaTT.setText(strTT);
            
            QLTT_HLV.SelectionListener listener1 = new QLTT_HLV.SelectionListener(tb1);
            tb1.getSelectionModel().addListSelectionListener(listener1);
            QLTT_HLV.SelectionListener listener = new QLTT_HLV.SelectionListener(tb);
            tb.getSelectionModel().addListSelectionListener(listener);
        } catch (Exception ex) {
         JOptionPane.showMessageDialog(null,ex.getMessage(),"Thong bao",JOptionPane.INFORMATION_MESSAGE);
        }
        
    }

    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        TabTT = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        pnsukien = new javax.swing.JPanel();
        btnDangkyHLV = new javax.swing.JButton();
        btnSuaHLV = new javax.swing.JButton();
        btnXoaHLV = new javax.swing.JButton();
        btnRefreshHLV = new javax.swing.JButton();
        btnTroveHLV = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        txtMaHLV = new javax.swing.JTextField();
        txtTenHLV = new javax.swing.JTextField();
        cmbQuoctich = new javax.swing.JComboBox();
        jLabel14 = new javax.swing.JLabel();
        dtpNamSinhHLV = new com.toedter.calendar.JDateChooser();
        dgvHLV = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        txtMaTT = new javax.swing.JTextField();
        txtTenTT = new javax.swing.JTextField();
        cmbQuocTichTT = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        dtpNamsinhTT = new com.toedter.calendar.JDateChooser();
        jLabel1 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        btnDangKyTT = new javax.swing.JButton();
        btnSuaTT = new javax.swing.JButton();
        btnXoaTT = new javax.swing.JButton();
        btnRefreshTT = new javax.swing.JButton();
        btnTrove = new javax.swing.JButton();
        dgvTrongTai = new javax.swing.JPanel();

        TabTT.setToolTipText("dsfds");
        TabTT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                TabTTMouseClicked(evt);
            }
        });
        TabTT.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                TabTTStateChanged(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel10.setText("QUẢN LÝ HLV");

        pnsukien.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        btnDangkyHLV.setText("Đăng ký");
        btnDangkyHLV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDangkyHLVActionPerformed(evt);
            }
        });

        btnSuaHLV.setText("Sửa");
        btnSuaHLV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSuaHLVActionPerformed(evt);
            }
        });

        btnXoaHLV.setText("Xóa");
        btnXoaHLV.setToolTipText("");
        btnXoaHLV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnXoaHLVActionPerformed(evt);
            }
        });

        btnRefreshHLV.setText("Refresh");
        btnRefreshHLV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRefreshHLVActionPerformed(evt);
            }
        });

        btnTroveHLV.setText("Trở về");
        btnTroveHLV.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTroveHLVActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnsukienLayout = new javax.swing.GroupLayout(pnsukien);
        pnsukien.setLayout(pnsukienLayout);
        pnsukienLayout.setHorizontalGroup(
            pnsukienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnsukienLayout.createSequentialGroup()
                .addGap(49, 49, 49)
                .addComponent(btnDangkyHLV, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(53, 53, 53)
                .addComponent(btnSuaHLV, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(62, 62, 62)
                .addComponent(btnXoaHLV, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86, Short.MAX_VALUE)
                .addComponent(btnRefreshHLV, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(53, 53, 53)
                .addComponent(btnTroveHLV, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(50, 50, 50))
        );
        pnsukienLayout.setVerticalGroup(
            pnsukienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnsukienLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnsukienLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnDangkyHLV, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnSuaHLV, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnXoaHLV, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnRefreshHLV, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnTroveHLV, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(24, Short.MAX_VALUE))
        );

        jPanel8.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel11.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jLabel11.setText("Mã HLV:");

        jLabel12.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jLabel12.setText("Tên HLV:");

        jLabel13.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jLabel13.setText("Quốc Tịch:");

        txtMaHLV.setEditable(false);

        cmbQuoctich.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Việt Nam", "Lào", "Thái Lan", "Mỹ", "Brazil", "England" }));

        jLabel14.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jLabel14.setText("Năm sinh:");

        dtpNamSinhHLV.setDateFormatString("MM/dd/yyyy");

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGap(88, 88, 88)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel11)
                    .addComponent(jLabel14))
                .addGap(18, 18, 18)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(dtpNamSinhHLV, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE)
                    .addComponent(txtMaHLV))
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGap(91, 91, 91)
                        .addComponent(jLabel12))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                        .addGap(83, 83, 83)
                        .addComponent(jLabel13)))
                .addGap(18, 18, 18)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtTenHLV)
                    .addComponent(cmbQuoctich, 0, 186, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jLabel12)
                    .addComponent(txtMaHLV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtTenHLV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cmbQuoctich, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel13)
                        .addComponent(jLabel14))
                    .addComponent(dtpNamSinhHLV, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(15, Short.MAX_VALUE))
        );

        dgvHLV.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        javax.swing.GroupLayout dgvHLVLayout = new javax.swing.GroupLayout(dgvHLV);
        dgvHLV.setLayout(dgvHLVLayout);
        dgvHLVLayout.setHorizontalGroup(
            dgvHLVLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        dgvHLVLayout.setVerticalGroup(
            dgvHLVLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 267, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(pnsukien, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(dgvHLV, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(318, 318, 318)
                        .addComponent(jLabel10)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(jLabel10)
                .addGap(18, 18, 18)
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pnsukien, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(dgvHLV, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        TabTT.addTab("Quản Lý HLV", jPanel2);

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel2.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jLabel2.setText("Mã TT:");

        jLabel3.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jLabel3.setText("Tên TT:");

        jLabel4.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jLabel4.setText("Quốc Tịch:");

        txtMaTT.setEditable(false);

        cmbQuocTichTT.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Việt Nam", "Lào", "Thái Lan", "Mỹ", "Brazil", "England" }));

        jLabel5.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jLabel5.setText("Năm sinh:");

        dtpNamsinhTT.setDateFormatString("MM/dd/yyyy");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(88, 88, 88)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel2))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtMaTT)
                    .addComponent(dtpNamsinhTT, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE))
                .addGap(84, 84, 84)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtTenTT)
                    .addComponent(cmbQuocTichTT, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(txtMaTT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtTenTT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cmbQuocTichTT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel5)
                            .addComponent(dtpNamsinhTT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel1.setText("QUẢN LÝ TRỌNG TÀI");

        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        btnDangKyTT.setText("Đăng ký");
        btnDangKyTT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDangKyTTActionPerformed(evt);
            }
        });

        btnSuaTT.setText("Sửa");
        btnSuaTT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSuaTTActionPerformed(evt);
            }
        });

        btnXoaTT.setText("Xóa");
        btnXoaTT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnXoaTTActionPerformed(evt);
            }
        });

        btnRefreshTT.setText("Refresh");
        btnRefreshTT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRefreshTTActionPerformed(evt);
            }
        });

        btnTrove.setText("Trở về");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(49, 49, 49)
                .addComponent(btnDangKyTT, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(53, 53, 53)
                .addComponent(btnSuaTT, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(62, 62, 62)
                .addComponent(btnXoaTT, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86, Short.MAX_VALUE)
                .addComponent(btnRefreshTT, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(53, 53, 53)
                .addComponent(btnTrove, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(50, 50, 50))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnDangKyTT, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnSuaTT, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnXoaTT, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnRefreshTT, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnTrove, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(24, Short.MAX_VALUE))
        );

        dgvTrongTai.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        javax.swing.GroupLayout dgvTrongTaiLayout = new javax.swing.GroupLayout(dgvTrongTai);
        dgvTrongTai.setLayout(dgvTrongTaiLayout);
        dgvTrongTaiLayout.setHorizontalGroup(
            dgvTrongTaiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        dgvTrongTaiLayout.setVerticalGroup(
            dgvTrongTaiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 267, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(dgvTrongTai, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(266, 266, 266)
                        .addComponent(jLabel1)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(dgvTrongTai, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        TabTT.addTab("Quản Lý Trọng Tài", jPanel1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(TabTT)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(TabTT)
        );

        TabTT.getAccessibleContext().setAccessibleName("qlTT");
        TabTT.getAccessibleContext().setAccessibleDescription("");
    }// </editor-fold>//GEN-END:initComponents

    private void btnDangkyHLVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDangkyHLVActionPerformed
        
        
        ngDTO.setManguoi(txtMaHLV.getText().trim());
        ngDTO.setHoten(txtTenHLV.getText().trim());
        dtpNamSinhHLV.setDateFormatString("MM/dd/yyyy");
        Calendar cal = dtpNamSinhHLV.getCalendar();
        int datevar= cal.get(Calendar.DATE);
        int monthvar = cal.get(Calendar.MONTH);
        int yearvar = cal.get(Calendar.YEAR)-1900;
       
     
        Date d= new Date(yearvar, monthvar, datevar);
        ngDTO.setDate(d);
        ngDTO.setQuoctich(cmbQuoctich.getSelectedItem().toString());
        hlvDTO.setNguoi(ngDTO);

        hlvBLO.Insert(hlvDTO);
        
        
           loadDataHLV();
        
        
        
    }//GEN-LAST:event_btnDangkyHLVActionPerformed

    private void btnSuaHLVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSuaHLVActionPerformed
       
        ngDTO.setManguoi(txtMaHLV.getText().trim());
        ngDTO.setHoten(txtTenHLV.getText().trim());
        dtpNamSinhHLV.setDateFormatString("MM/dd/yyyy");
        Calendar cal = dtpNamSinhHLV.getCalendar();
        int datevar= cal.get(Calendar.DATE);
        int monthvar = cal.get(Calendar.MONTH);
        int yearvar = cal.get(Calendar.YEAR)-1900;
       
     
        Date d= new Date(yearvar, monthvar, datevar);
        ngDTO.setDate(d);
        ngDTO.setQuoctich(cmbQuoctich.getSelectedItem().toString());
        hlvDTO.setNguoi(ngDTO);

        hlvBLO.Update(hlvDTO);
        loadDataHLV();
        
           
    }//GEN-LAST:event_btnSuaHLVActionPerformed

    private void btnXoaHLVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnXoaHLVActionPerformed
        
        hlvBLO.Delete(txtMaHLV.getText().trim());
        loadDataHLV();
        
        
    }//GEN-LAST:event_btnXoaHLVActionPerformed

    private void btnRefreshHLVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshHLVActionPerformed
           String st1,str;
            Function fn = new Function();
               if(hlvBLO.LayMaCuoi().trim().length()==0)
                  st1="HL_00";
              else
                 st1 = hlvBLO.LayMaCuoi().trim();
           
            str = fn.ID_Ketiep(st1, "HL_");
            txtMaHLV.setText(str);
             txtTenHLV.setText("");
                
       
    }//GEN-LAST:event_btnRefreshHLVActionPerformed

    private void btnTroveHLVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTroveHLVActionPerformed
        this.setVisible(false);
    }//GEN-LAST:event_btnTroveHLVActionPerformed

    
    
    //trong tai---------------------------------
    
    private void btnDangKyTTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDangKyTTActionPerformed
       
        //JOptionPane.showMessageDialog(null,txtMaTT.getText().trim()+txtTenTT.getText().trim()+cmbQuocTichTT.getSelectedItem().toString());
        ngDTO.setManguoi(txtMaTT.getText().trim());
        ngDTO.setHoten(txtTenTT.getText().trim());
        dtpNamsinhTT.setDateFormatString("MM/dd/yyyy");
        Calendar cal = dtpNamsinhTT.getCalendar();
        int datevar= cal.get(Calendar.DATE);
        int monthvar = cal.get(Calendar.MONTH);
        int yearvar = cal.get(Calendar.YEAR)-1900;
       
     
        Date d= new Date(yearvar, monthvar, datevar);
        ngDTO.setDate(d);
        ngDTO.setQuoctich(cmbQuocTichTT.getSelectedItem().toString());
        ttDTO.setNguoi(ngDTO);
        
        
        ttBLO.Insert(ttDTO);
        
        //tao thu het rui loi ben kia
        
           loadDataTT();
    }//GEN-LAST:event_btnDangKyTTActionPerformed

    private void btnSuaTTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSuaTTActionPerformed
        
        ngDTO.setManguoi(txtMaTT.getText().trim());
        ngDTO.setHoten(txtTenTT.getText().trim());
        dtpNamsinhTT.setDateFormatString("MM/dd/yyyy");
        Calendar cal = dtpNamsinhTT.getCalendar();
        int datevar= cal.get(Calendar.DATE);
        int monthvar = cal.get(Calendar.MONTH);
        int yearvar = cal.get(Calendar.YEAR)-1900;
       
     
        Date d= new Date(yearvar, monthvar, datevar);
        ngDTO.setDate(d);
        ngDTO.setQuoctich(cmbQuocTichTT.getSelectedItem().toString());
        ttDTO.setNguoi(ngDTO);

        ttBLO.Update(ttDTO);
        loadDataTT();
    }//GEN-LAST:event_btnSuaTTActionPerformed

    private void btnXoaTTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnXoaTTActionPerformed
        
        ttBLO.Delete(txtMaTT.getText().trim());
        loadDataTT();
    }//GEN-LAST:event_btnXoaTTActionPerformed

    private void btnRefreshTTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshTTActionPerformed
          String st1,str;
            Function fn = new Function();
               if(ttBLO.LayMaCuoi().trim().length()==0)
                  st1="TT_00";
              else
                 st1 = ttBLO.LayMaCuoi().trim();
           
            str = fn.ID_Ketiep(st1, "TT_");
            txtMaTT.setText(str);
             txtTenTT.setText("");
       //txtNgaySinhTT.setText("");
    }//GEN-LAST:event_btnRefreshTTActionPerformed

    private void TabTTMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TabTTMouseClicked
        // TODO add your handling code here:
         //tab++;
    }//GEN-LAST:event_TabTTMouseClicked

    private void TabTTStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_TabTTStateChanged
        // TODO add your handling code here:
        tab++;
    }//GEN-LAST:event_TabTTStateChanged
    
    public void loadDataHLV()
    {
            ResultsModel dtable=  hlvBLO.Getdata1();
            JTable tb= new JTable(dtable);
            tb.setBounds(0,0,869,300);
            JScrollPane js= new JScrollPane(tb);
            js.setBounds(0,0,869,300);
            dgvHLV.removeAll();
            dgvHLV.add(js);
            
             QLTT_HLV.SelectionListener listener1 = new QLTT_HLV.SelectionListener(tb);
              tb.getSelectionModel().addListSelectionListener(listener1);
    }
    
    public void loadDataTT()
    {
            ResultsModel dtable=  ttBLO.Getdata1();
            JTable tb= new JTable(dtable);
             tb.setBounds(0,0,869,300);
            JScrollPane js= new JScrollPane(tb);
            js.setBounds(0,0,869,300);
            dgvTrongTai.removeAll();
            dgvTrongTai.add(js);
            
            QLTT_HLV.SelectionListener listener = new QLTT_HLV.SelectionListener(tb);
              tb.getSelectionModel().addListSelectionListener(listener);
    }
    
    
    class SelectionListener implements ListSelectionListener {
        JTable table;
         SelectionListener(JTable table) {
         this.table = table;}
         public void valueChanged(ListSelectionEvent e) {
                int row= table.getSelectedRow();
                if(row>=0)
                {
                    if(tab%2!=0)
                    {
                        txtMaTT.setText(table.getValueAt(row, 0).toString());
                        txtTenTT.setText(table.getValueAt(row,1).toString());
                        //txtNgaySinhTT.setText(table.getValueAt(row, 2).toString());
                        cmbQuocTichTT.setSelectedItem(table.getValueAt(row,3));
                    }
                    else
                    {
                        
                         txtMaHLV.setText(table.getValueAt(row,0).toString().trim());
                         txtTenHLV.setText(table.getValueAt(row,1).toString().trim());
                         //txtngaysinh.setText(table.getValueAt(row, 2).toString());
                         cmbQuoctich.setSelectedItem(table.getValueAt(row,3));
                    }
                }
    }
  }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane TabTT;
    private javax.swing.JButton btnDangKyTT;
    private javax.swing.JButton btnDangkyHLV;
    private javax.swing.JButton btnRefreshHLV;
    private javax.swing.JButton btnRefreshTT;
    private javax.swing.JButton btnSuaHLV;
    private javax.swing.JButton btnSuaTT;
    private javax.swing.JButton btnTrove;
    private javax.swing.JButton btnTroveHLV;
    private javax.swing.JButton btnXoaHLV;
    private javax.swing.JButton btnXoaTT;
    private javax.swing.JComboBox cmbQuocTichTT;
    private javax.swing.JComboBox cmbQuoctich;
    private javax.swing.JPanel dgvHLV;
    private javax.swing.JPanel dgvTrongTai;
    private com.toedter.calendar.JDateChooser dtpNamSinhHLV;
    private com.toedter.calendar.JDateChooser dtpNamsinhTT;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel pnsukien;
    private javax.swing.JTextField txtMaHLV;
    private javax.swing.JTextField txtMaTT;
    private javax.swing.JTextField txtTenHLV;
    private javax.swing.JTextField txtTenTT;
    // End of variables declaration//GEN-END:variables
}
